package com.cloud.servicehi.Controller;


import com.cloud.commons.entry.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


/**
 * @author: setsun
 * @create: 2018- 08-13
 * @description:
 * @program: xiaoshan-cloud-lcc
 **/
@Slf4j
@RestController
public class stringceshiController {


    @Autowired
    private RestTemplate restTemplate;

    private String url="http://service-lcc";
    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    public String home(@RequestParam(value = "name", defaultValue = "cloud") String names) {
        System.out.println("hi服务调用 lcc服务 ... ");
        User user = new User();
        user.setName("lcc服务");
        //服务于服务之间跨服务post请求 restTemplate.postForObject(请求注册中心地址eureka 服务名称/请求路径,实体类,返回的类型)
        User s = this.restTemplate.postForObject("http://service-lcc/lcc",user,User.class );
//        String s = this.restTemplate.getForObject(url + "/lcc?name="+name,String.class);
        log.info("s===>"+s.toString());
        return s + " hi 8762 " + port;
    }

}
